package com.hhs.storage.controller;


import com.hhs.storage.bean.BusinessDocument;
import com.hhs.storage.bean.BusinessOrder;
import com.hhs.storage.bean.InputParam;
import com.hhs.storage.service.BusinessOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author hhs
 * @since 2023-01-06
 */
@RestController
@RequestMapping("/businessOrder")
public class BusinessOrderController {
    @Autowired
    private BusinessOrderService businessOrderService;
//    @RequestMapping(value = "table")
//    public Map<String, Object> getAll(BusinessOrder businessOrder, InputParam inputParam) {
//        return businessOrderService.getAll(businessOrder,inputParam);
//    }
    @RequestMapping(value = "prepareDispatchOrders")
    public Map<String, Object> prepareDispatchOrders(BusinessOrder businessOrder, InputParam inputParam) {
        businessOrder.setState(BusinessOrder.STATUS_CREATE);//待调度的订单
        return businessOrderService.getAll(businessOrder,inputParam);
    }
    @PostMapping(value = "add")
    public Map<String, Object> addOrUpdate(BusinessOrder businessOrder,@RequestParam String dataJson){
        return businessOrderService.add(businessOrder,dataJson);
    }
    @PostMapping(value = "changeOrderCarFleet")
    public Map<String, Object> changeOrderCarFleet(@RequestParam String id,@RequestParam String carFleetId){
        return businessOrderService.changeOrderCarFleet(id,carFleetId);
    }

    //根据document的id，获取该单据下已分配的车队数据
   @PostMapping(value = "getByDocuId")
    public Map<String, Object> getByDocuId(InputParam inputParam){
        return businessOrderService.getByDocuId(inputParam);
    }
}

